package devdocs

import edu.uow.devdocs.DevelopmentTask
import edu.uow.devdocs.DevelopmentChecklist

class ListTagsTagLib {
	
	def filterColumn = { attrs, body ->
		out << attrs.domain
		out << attrs.property
		
	}
	
	def formatDomainList = { attrs, body ->
		out << '<ul>'
		attrs.list.each{
			out << '<li>'
			out << getLink(it)
			out << '</li>'
		}
		out << '</ul>'
		
	}
	
	private String getLink(obj) {
		def url
		if (obj instanceof DevelopmentTask) {
			url = link(action:'edit', controller: 'developmentTask', id:obj.id, obj.task)
		} else if (obj instanceof DevelopmentChecklist) {
			url = link(action:'edit', controller: 'developmentChecklist', id:obj.id, obj.description)
		} else {
			url = link(action:'edit', id:obj.id, obj)
		}
		return url
	}

}
